<?php
/**
 * Created by PhpStorm.
 * User: sunzexin
 * Date: 2018/2/28
 * Time: 15:20
 */

namespace App\Http\Traits;


use Illuminate\Http\Request;

trait CategoryTrait
{
    use BaseTrait;

    // 父分类ID
    protected $parent_id;
    // 新的排序字符串
    protected $new_sort_str;
    // 分类名称
    protected $name;
    // 分类图标
    protected $icon;
    // 分类图标文件
    protected $icon_file;
    // 分类ID
    protected $category_id;
    // 分类Banner
    protected $banner;

    public function __construct(Request $request)
    {
        $this->parent_id = $request->input('parent_id', 0);
        $this->new_sort_str = $request->input('new_sort_str', '');
        $this->name = $request->input('name', '');
        $this->icon = $request->input('icon', '');
        if (!empty($request->file('file', ''))){
            $this->icon_file = $request->file('file', '')->store('temp');
        }
        $this->category_id = $request->input('category_id', 0);
        $this->banner = $request->input('banner', '');
    }
}